/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package DA;

import BO.Concepto;
import BO.Funcionario;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Daniel.Cerdas
 */
public class DAConceptos {
    String conexionString = "jdbc:sqlserver://localhost:1433;" +
            "databaseName=Viaticos;user=sa; password=admin;";        
    
    Connection con = null;
    PreparedStatement pstmt = null;
    Statement stmt= null;
    ResultSet rs = null; 
    public ArrayList obtenerConceptos() throws SQLException
    {
        ArrayList lista= new ArrayList();
    try {
        Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
        con = DriverManager.getConnection(conexionString);
        stmt= con.createStatement();
        String SQL = "select  * from Concepto;"; 
        rs = stmt.executeQuery(SQL);
        while ( rs.next() ) {
            String DescripcionConcepto= rs.getString("DescripcionConcepto");
            String idConcepto = rs.getString("idConcepto");
            double Monto = rs.getDouble("Monto");
            Concepto conceptos = new Concepto(DescripcionConcepto, idConcepto, Monto);
            lista.add(conceptos);
        }
        con.close();
    } catch (ClassNotFoundException ex) {
        Logger.getLogger(DAConceptos.class.getName()).log(Level.SEVERE, null, ex);
    }
    
    return lista;
        
    }
}
